
$(function() {
	Tip.emp('负责人');
	
	$("input[id^='date']:visible").datepicker(_date1_option);
	
	$('textarea').css("width", 400);
	
	var options = {
			editable: true,
		    enableAddRow: false,
		    enableCellNavigation: true,
		    asyncEditorLoading: false,
		    rowHeight: 30
		};	
	
	// alert(data);
	
	var grid = new Slick.Grid($("#myGrid"), salary_data, columns, options);
	
	grid.onCellChange.subscribe(function(e, args) {
		item = args.item;
		currentCell = args.cell;
		currentRow = args.row;
		
		// alert(currentRow);
		// alert(currentCell);
		
		if (currentCell == 15) {
			item.ns = item.t2 - item.sj;
			// alert(item.ns);
    	}
		
		if (currentCell == 16) {
			item.sj = item.t2 - item.ns;
			// alert(item.sj)
    	}
		
		grid.updateRowCount();
	    grid.render();
	});
});

function _currency(s) {
	if (s == null || s == '-')　{		
		return false;
	}
	
	var body = { };
	body.currency = s;
	$.post('finance.php?do=Finance.ajax_exchange', body, function(s) {
		exchange = s;
		$('#rate').val(s);
		
		_update();
	});
}

function _update() {
	var a = $("#amount").val();
	var b = $("#currency").find("option:selected").text();
	
	a = a.replace(/,/g, '');

	Currency.upper(a, b, "#label_amount");
	
	_rmb();
} 

function _rmb() {
	var a = $("#amount").val();
	var b = $('#rate').val();
	
	a = a.replace(/,/g, '');
	b = b.replace(/,/g, '');
	
	var rmb = fxmul(a, b);
	
	$('#rmb').val(rmb);	
}